// JavaScript Document
// JavaScript Document
// JavaScript Document

$(function(){


var storecheckouttitle_paypal;
var storecheckouttitle_2checkout;
var store2checkoutid;
var store2checkoutselected;
var storepaypalselected;


/*
$("[id^='shpinfobtn-']").live('click', function() {
	
		var btnid = $(this).attr("id");
		alert("btnid=" + btnid);
		
});
*/

	$("body").click(function(event) {
														  
							  	var id = event.target.id;
								var targetnodename = event.target.nodeName;
								eventcapture="true";
								
								
						
							
			if 	(id=="viewcartbtn"){
				
			
								
					if (isitemexists=="false" && item_name_arry.arrylength()==0){
						
								document.getElementById("itembx").innerHTML="";
								document.getElementById("ctotals").innerHTML="";
								
								$("#buywith2co").html("");
								$("#buywithpaypal").html("");
								
								
								var displaystr = "<p>Your cart is Empty</p> ";
								$('#itembx').append($(displaystr));
								
					}else if(item_name_arry.arrylength()>0){
						
									document.getElementById("itembx").innerHTML="";
									document.getElementById("ctotals").innerHTML="";
									
									$("#buywith2co").html("");
									$("#buywithpaypal").html("");
								
									
									
									functionexecuted=additemstoul();		
									
																			 
						
					}
					
					
			}  // end of view cart
			
			
							
								
			if (id.indexOf("deleteitem") >= 0 ){
								
										
						lenoftargetid = id.length;
						var position=id.substr(lenoftargetid-1,1);
										
										//return false;
										
										
						 item_name_arry.removeitem(position);
						 item_number_arry.removeitem(position);
						 item_amount_arry.removeitem(position);
						 item_quantity_arry.removeitem(position);
						 item_shipping_arry.removeitem(position);
						 item_shipping2_arry.removeitem(position);
						 item_option1title_arry.removeitem(position);
						 item_option1value_arry.removeitem(position);
						 item_option2title_arry.removeitem(position);
						 item_option2value_arry.removeitem(position);
						 item_img_arry.removeitem(position);
						 item_2cprodid_arry.removeitem(position);
									 
						  if (item_name_arry.arrylength()==0) {
							  isitemexists="false";
						  }

										 // document.getElementById("total").innerHTML="";
				  	 	document.getElementById("itembx").innerHTML="";
					  	document.getElementById("ctotals").innerHTML="";
						
						$("#buywith2co").html("");
						$("#buywithpaypal").html("");
									
						
						functionexecuted=additemstoul();
						 
						 
					 return false;
										 
										
			}  // end of delete item
								
	//	alert(id.indexOf("addtocartstore-"));					
	
	
	$("#shpclose").click(function(){
					$(this).parent("#shippinginfoBx").css({display:'none'});
					return false;
					
	});
	
		
		if (targetnodename=="INPUT" && id.indexOf("shpinfobtn-")>=0 ){
			
			
			
			
			$("#shippinginfoBx").css({display:'block'});
			
			
			var formname;
			id=id.replace("shpinfobtn-","");
			
			formname = "form" + id;
			var formid = "#" + formname;
			
			
			
			 var shippingval = $("#form" +  id  +  "  input[name=shipping]").val() ; 
			 var shipping2val = $("#form" +  id  +  "  input[name=shipping2]").val() ; 
			 
			
			 
			 $("#shippfirstitem").html(shippingval);
			 $("#shippadditionalitem").html(shipping2val);
			 
			
			
		}
		
		
		
		
		if (targetnodename=="INPUT" && id.indexOf("addtocartstore-")>=0 ){
			
			
			
				
						var formname;
						id=id.replace("addtocartstore-","");
						//alert("id=" + id);
						formname = "form" + id;
						var formid = "#" + formname;
										
									
										// var quantity=$("'#form"+id+" select[name=quantity]'").val(); 
										 
										// var quan = $("#form1 input[name=item_name]").val() 
										
									  ////////// New form of assigning values ////////////////////
									  


											 var quantity = $("#form" +  id  +  "  select[name=quantity]").val() ;
											 
											// alert(quantity);
											 
											 var item_name = $("#form" +  id  +  "  input[name=item_name]").val() ;
											 
											 var item_number = $("#form" +  id  +  "  input[name=item_number]").val() ;
											 
											 var amount = $("#form" +  id  +  "  input[name=amount]").val() ;
											 
											// alert(amount);
											 
											
											 var shipping = $("#form" +  id  +  "  input[name=shipping]").val() ; 
											 
											 var shipping2var = $("#form" +  id  +  "  input[name=shipping2]").val() ; 
											 

											var option1title = $("#form" +  id  +  "  input[name=option1title]").val() ; 	
											
											
											var option2title = $("#form" +  id  +  "  input[name=option2title]").val() ; 	
											
											
											var item_option1var = $("#form" +  id  +  "  select[name=item_option1]").val() ; 	
											
											
											var item_option2var = $("#form" +  id  +  "  select[name=item_option2]").val() ; 	
											
						
											
											var storeitemtitle = $("#form" +  id  +  "  input[name=storeitemtitle]").val() ; 	
											
											var storeitempricetitle = $("#form" +  id  +  "  input[name=storeitempricetitle]").val() ; 	
											
											
											var storequantitytitle = $("#form" +  id  +  "  input[name=storequantitytitle]").val() ; 	
											
											var storetotaltitle = $("#form" +  id  +  "  input[name=storetotaltitle]").val() ; 	
											
											var storeshippingtitle = $("#form" +  id  +  "  input[name=storeshippingtitle]").val() ; 	
											
											var storeitemstotaltitle = $("#form" +  id  +  "  input[name=storeitemstotaltitle]").val() ; 	
											
											var storeshippingtotaltitle = $("#form" +  id  +  "  input[name=storeshippingtotaltitle]").val() ; 	
											
											storepaypalid = $("#form" +  id  +  "  input[name=storepaypalid]").val() ; 	
											
											store2checkoutid = $("#form" +  id  +  "  input[name=store2checkoutid]").val() ; 	
											
											storepaypalselected = $("#form" +  id  +  "  input[name=storepaypalselected]").val() ; 	
											
											store2checkoutselected = $("#form" +  id  +  "  input[name=store2checkoutselected]").val() ; 	
											
											
											storecheckouttitle_paypal = $("#form" +  id  +  "  input[name=storecheckouttitle_paypal]").val() ; 	
											
											storecheckouttitle_2checkout = $("#form" +  id  +  "  input[name=storecheckouttitle_2checkout]").val() ; 	
											
											
											var stc2cprodid= $("#form" +  id  +  "  input[name=stc2cprodid]").val() ; 	
											
											
											
											var storecurrency = $("#form" +  id  +  "  input[name=storecurrency]").val() ; 	
											
											var storedeflocation = $("#form" +  id  +  "  input[name=storedeflocation]").val() ; 	
											
											
											var instock = $("#form" +  id  +  "  input[name=instock]").val() ; 	
											
											var outofstockvar = $("#form" +  id  +  "  input[name=outofstockvar]").val() ; 	
											
											var imgvar = $("#form" +  id  +  "  input[name=imgvar]").val() ; 	
											
											var imgtitle = $("#form" +  id  +  "  input[name=imgtitle]").val() ; 	
											
											
											
												
											
									  ////////////////////////////////////////////////////////////
										
										
										 
									 
										// alert("test1");
										 
										// alert("quantity="  + quantity);
										//
										/*
										

										 var item_name=$("'#form"+id+" input[name=item_name]'").val(); 
										 var item_number=$("'#form"+id+" input[name=item_number]'").val(); 
										 var amount=$("'#form"+id+" input[name=amount]'").val(); 
										 var shipping=$("'#form"+id+" input[name=shipping]'").val(); 
										 
										 
										 
										 
										 var shipping2var=$("'#form"+id+" input[name=shipping2]'").val(); 
										 var option1title=$("'#form"+id+" input[name=option1title]'").val(); 
										 var option2title=$("'#form"+id+" input[name=option2title]'").val(); 
	    								 var item_option1var=$("'#form"+id+" select[name=item_option1]'").val(); 
										 alert(item_option1var);
										 
										 var item_option2var=$("'#form"+id+" select[name=item_option2]'").val(); 
										 
										 alert(item_option2var);
										 
									
										 
										// var storeimagetitle=$("'#form"+id+" input[name=storeimagetitle]'").val(); 
										 var storeitemtitle=$("'#form"+id+" input[name=storeitemtitle]'").val(); 
										 var storeitempricetitle=$("'#form"+id+" input[name=storeitempricetitle]'").val(); 
										 var storequantitytitle=$("'#form"+id+" input[name=storequantitytitle]'").val(); 
										 var storetotaltitle=$("'#form"+id+" input[name=storetotaltitle]'").val(); 
										 var storeshippingtitle=$("'#form"+id+" input[name=storeshippingtitle]'").val(); 
										 var storeitemstotaltitle=$("'#form"+id+" input[name=storeitemstotaltitle]'").val(); 
										 var storeshippingtotaltitle=$("'#form"+id+" input[name=storeshippingtotaltitle]'").val(); 
										 var storepaypalid=$("'#form"+id+" input[name=storepaypalid]'").val();
										 var storecurrency=$("'#form"+id+" input[name=storecurrency]'").val();
										 var storedeflocation=$("'#form"+id+" input[name=storedeflocation]'").val();
										 var instock=$("'#form"+id+" input[name=instock]'").val();
										 var outofstockvar=$("'#form"+id+" input[name=outofstockvar]'").val();
										 */
										// alert("instock:" + instock);
										// alert("outofstockvar:" + outofstockvar);
										 
										 if (instock=="no") {
											 	//alert(outofstockvar);
												//alert("outofstock");
												
												document.getElementById("statustext").innerHTML="";
												//var displaystr = "Item Added to your cart !";
												document.getElementById("statustext").innerHTML=outofstockvar;
												
												
												return false;
										 }
										else{	 
											 
										 
										// alert("stock is there");
										 
										 //var storeimgname=$("'#form"+id+" input[name=storeimgname]'").val();
										 
										 
										
										 	// alert("item_option1var" + item_option1var);
										// alert("item_option2var" + item_option2var);
										 
										
										//alert("name=" + item_name);
										
										
										
										 item_name_arry.add(item_name);
									     item_number_arry.add(item_number);
										 item_amount_arry.add(amount);
										 item_quantity_arry.add(quantity);
										 item_shipping_arry.add(shipping);
										 item_shipping2_arry.add(shipping2var);
										 item_option1title_arry.add(option1title);
										 item_option1value_arry.add(item_option1var);
										 item_option2title_arry.add(option2title);
										 item_option2value_arry.add(item_option2var);
										 item_2cprodid_arry.add(stc2cprodid);
										 item_img_arry.add(imgvar)
										
										 
										 
										 
										 //item_imgname_arry.add(storeimgname);
										 										 
										// $.cookie('storeimagetitle_ck', storeimagetitle);
										 $.cookie('storeitemtitle_ck', storeitemtitle);
										 $.cookie('storeitempricetitle_ck', storeitempricetitle);
										 $.cookie('storequantitytitle_ck', storequantitytitle);
										 $.cookie('storetotaltitle_ck', storetotaltitle);
										 $.cookie('storeshippingtitle_ck', storeshippingtitle);
										 $.cookie('storeitemstotaltitle_ck', storeitemstotaltitle);
										 $.cookie('storeshippingtotaltitle_ck', storeshippingtotaltitle);
										 $.cookie('storepaypalid_ck', storepaypalid);
										 $.cookie('storecurrency_ck', storecurrency);
										 $.cookie('storedeflocation_ck', storedeflocation);
										 $.cookie('imgtitle_ck', imgtitle);
										 $.cookie('storecheckouttitle_paypal', storecheckouttitle_paypal);
										 $.cookie('storecheckouttitle_2checkout', storecheckouttitle_2checkout);
										 $.cookie('store2checkoutid', store2checkoutid);
										 $.cookie('store2checkoutselected', store2checkoutselected);
										 $.cookie('storepaypalselected', storepaypalselected);
										 
										 
	
										 document.getElementById("itembx").innerHTML="";
										 document.getElementById("ctotals").innerHTML="";
										 //document.getElementById("total").innerHTML="";
										// alert("Item added");
										document.getElementById("statustext").innerHTML="";
										var displaystr = "Item Added to your cart !";
										//alert(displaystr);
										
										//$('#statustext').append($(displaystr));
										document.getElementById("statustext").innerHTML=displaystr;
										
										
										
										
										 functionexecuted=additemstoul();
										 
										 
										
										 return false;
										 
										}
														 
								}
								
								
								
							
				
				
				
								
								
								
								
					
				});
				
				
				
	$('body').bind('tap', function(event){
												   
												   
							 	var id = event.target.id;
								var targetnodename = event.target.nodeName;
								eventcapture="true";
							
							
			if 	(id=="infoButton"){
				//alert(item_name_arry.arrylength());
					if (isitemexists=="false" && item_name_arry.arrylength()==0){
								document.getElementById("ul-viewcart").innerHTML="";
								var displaystr = "<p>Your cart is Empty</p> ";
								//alert(displaystr);
								$('#div-viewcart .rounded').append($(displaystr));
					}
					else if(item_name_arry.arrylength()>0){
						
									document.getElementById("ul-viewcart").innerHTML="";
									
									functionexecuted=additemstoul();												
										 
						
					}
			}
			
			
							
								
								if (id.indexOf("deleteitem") >= 0 )
								{
								
										//alert("before delete:"+item_name_arry.arrylength());
								
										lenoftargetid = id.length;
										var position=id.substr(lenoftargetid-1,1);
										//alert("nth value:"+targetstr);
										//return false;
										
										//alert("position:"+position);
										 item_name_arry.removeitem(position);
										 item_number_arry.removeitem(position);
										 item_amount_arry.removeitem(position);
										 item_quantity_arry.removeitem(position);
										 item_shipping_arry.removeitem(position);
										 item_shipping2_arry.removeitem(position);
										 item_option1title_arry.removeitem(position);
										 item_option1value_arry.removeitem(position);
										 item_option2title_arry.removeitem(position);
										 item_option2value_arry.removeitem(position);
										 item_2cprodid_arry.removeitem(position);
									 
									
										 
										 
										 // alert("item length:"+item_name_arry.arrylength());
										  if (item_name_arry.arrylength()==0) {
											  isitemexists="false";
										  }
										  //alert(isitemexists);
										  document.getElementById("ul-viewcart").innerHTML="";
										 // document.getElementById("total").innerHTML="";
										//  alert("before delete:"+ isitemexists);
										 // functionexecuted=additemstoul();
										  return false;
										 
										
								}
								
								
			if (targetnodename=="INPUT" && id.indexOf("addtocartstore-")>=0){
								      // alert("in");
										var formname;
										id=id.replace("addtocartstore-","");
										formname = "form" + id;
										//"#form1 input[name=option1]"
										
													
										 var quantity=$("'#form"+id+" select[name=quantity]'").val(); 
										 var item_name=$("'#form"+id+" input[name=item_name]'").val(); 
										 var item_number=$("'#form"+id+" input[name=item_number]'").val(); 
										 var amount=$("'#form"+id+" input[name=amount]'").val(); 
										 var shipping=$("'#form"+id+" input[name=shipping]'").val(); 
										 
										 
										 var shipping2var=$("'#form"+id+" input[name=shipping2]'").val(); 
										 var option1title=$("'#form"+id+" input[name=option1title]'").val(); 
										 var option2title=$("'#form"+id+" input[name=option2title]'").val(); 
	    								 var item_option1var=$("'#form"+id+" select[name=item_option1]'").val(); 
										 var item_option2var=$("'#form"+id+" select[name=item_option2]'").val(); 
										 
										 
										 
										// var storeimagetitle=$("'#form"+id+" input[name=storeimagetitle]'").val(); 
										 var storeitemtitle=$("'#form"+id+" input[name=storeitemtitle]'").val(); 
										 var storeitempricetitle=$("'#form"+id+" input[name=storeitempricetitle]'").val(); 
										 var storequantitytitle=$("'#form"+id+" input[name=storequantitytitle]'").val(); 
										 var storetotaltitle=$("'#form"+id+" input[name=storetotaltitle]'").val(); 
										 var storeshippingtitle=$("'#form"+id+" input[name=storeshippingtitle]'").val(); 
										 var storeitemstotaltitle=$("'#form"+id+" input[name=storeitemstotaltitle]'").val(); 
										 var storeshippingtotaltitle=$("'#form"+id+" input[name=storeshippingtotaltitle]'").val(); 
										 storepaypalid=$("'#form"+id+" input[name=storepaypalid]'").val();
										 store2checkoutid = $("#form" +  id  +  "  input[name=store2checkoutid]").val() ; 	
										 storepaypalselected = $("#form" +  id  +  "  input[name=storepaypalselected]").val() ; 	
										 store2checkoutselected = $("#form" +  id  +  "  input[name=store2checkoutselected]").val() ; 	
										 storecheckouttitle_paypal = $("#form" +  id  +  "  input[name=storecheckouttitle_paypal]").val() ; 	
										 storecheckouttitle_2checkout = $("#form" +  id  +  "  input[name=storecheckouttitle_2checkout]").val() ; 	
									
										 var stc2cprodid= $("#form" +  id  +  "  input[name=stc2cprodid]").val() ; 
										 var storecurrency=$("'#form"+id+" input[name=storecurrency]'").val();
										 var storedeflocation=$("'#form"+id+" input[name=storedeflocation]'").val();
										 //var storeimgname=$("'#form"+id+" input[name=storeimgname]'").val();
										 var instock=$("'#form"+id+" input[name=instock]'").val();
										 var outofstockvar=$("'#form"+id+" input[name=outofstockvar]'").val();
										 
										// alert("instock:" + instock);
										// alert("outofstockvar:" + outofstockvar);
										 
										 if (instock=="no") {
											 	alert(outofstockvar);
												return false;
										 }
										else{	 
										
										 
										
										 
										 item_name_arry.add(item_name);
										 item_number_arry.add(item_number);
										 item_amount_arry.add(amount);
										 item_quantity_arry.add(quantity);
										 item_shipping_arry.add(shipping);
										 item_shipping2_arry.add(shipping2var);
										 item_option1title_arry.add(option1title);
										 item_option1value_arry.add(item_option1var);
										 item_option2title_arry.add(option2title);
										 item_option2value_arry.add(item_option2var);
										 item_2cprodid_arry.add(stc2cprodid);
										 
										 //item_imgname_arry.add(storeimgname);
										 										 
										// $.cookie('storeimagetitle_ck', storeimagetitle);
										 $.cookie('storeitemtitle_ck', storeitemtitle);
										 $.cookie('storeitempricetitle_ck', storeitempricetitle);
										 $.cookie('storequantitytitle_ck', storequantitytitle);
										 $.cookie('storetotaltitle_ck', storetotaltitle);
										 $.cookie('storeshippingtitle_ck', storeshippingtitle);
										 $.cookie('storeitemstotaltitle_ck', storeitemstotaltitle);
										 $.cookie('storeshippingtotaltitle_ck', storeshippingtotaltitle);
										 $.cookie('storepaypalid_ck', storepaypalid);
										 $.cookie('storecurrency_ck', storecurrency);
										 $.cookie('storedeflocation_ck', storedeflocation);
										 
										 
										 $.cookie('storecheckouttitle_paypal', storecheckouttitle_paypal);
										 $.cookie('storecheckouttitle_2checkout', storecheckouttitle_2checkout);
										 $.cookie('store2checkoutid', store2checkoutid);
										 $.cookie('store2checkoutselected', store2checkoutselected);
										 $.cookie('storepaypalselected', storepaypalselected);
									

										 document.getElementById("ul-viewcart").innerHTML="";
										// document.getElementById("total").innerHTML="";
										// alert("Item added");
										// functionexecuted=additemstoul();
										 
										 return false;
										 
										}
														 
								}
								
								
					
				
				
			   
												   
												   
												   
				
				});
	
	

			function additemstoul(){
				
				
					
									     var emptystr="";
										 var str="";
										 var hiddenvars="";
										 var hiddenvars_2co="";
										 var itemtotal=0;
										 var shippingtotal=0;
										 var k ;
										 var tmpshippingcost=0;
										 
										 
										
										 
									for (var i = 0;i<item_name_arry.arrylength();i++)
									{
										
									
											var deleteitemname = "deleteitem-" + i ;
									
											
											if (item_option1title_arry.getitem(i)!="" && item_option1title_arry.getitem(i)!="undefined" && item_option1title_arry.getitem(i)!="NAN" && item_option1title_arry.getitem(i)!="--option-not-set--" && item_option1title_arry.getitem(i)!=item_option1value_arry.getitem(i) &&   item_option1title_arry.getitem(i)!="none" ){
													//str = str + "<li>" +   item_option1title_arry.getitem(i) +  ": " + item_option1value_arry.getitem(i) + "</li>";
												options1var = "</br> <span>{"+   item_option1title_arry.getitem(i) +  ": " + item_option1value_arry.getitem(i)  + "}</span>" ;
													
											}else{
												options1var="";
												
											}
											
											
	if (item_option2title_arry.getitem(i)!="" && item_option2title_arry.getitem(i)!="undefined" && item_option2title_arry.getitem(i)!="NAN" && item_option2title_arry.getitem(i)!="--option-not-set--" && item_option2title_arry.getitem(i)!=item_option2value_arry.getitem(i) &&  item_option2title_arry.getitem(i)!="none"){
													//str = str + "<li>" +   item_option2title_arry.getitem(i) +  ": " + item_option2value_arry.getitem(i) + "</li>";
													options2var = "</br> <span>{"+   item_option2title_arry.getitem(i) +  ": " + item_option2value_arry.getitem(i)  + "}</span>" ;
													
											}else{
												
												options2var="";
												
											}
											
																					
											tmpshippingcost = ( (1*item_shipping_arry.getitem(i)) + ( (item_quantity_arry.getitem(i)-1)*item_shipping2_arry.getitem(i)   ) );							
											tmpshippingcost =  parseFloat(tmpshippingcost).toFixed(2); 
											
											str = str + "<ul class='slct'>" ;
											str = str + "<li class='b1'><img src='"  + item_img_arry.getitem(i) +  "' class='strimg'> "  + item_name_arry.getitem(i)  +  options1var  + options2var + "</li>" ;
											str = str + "<li class='b2'>"  +  item_amount_arry.getitem(i)  + "</li>" ; 
											str =  str + "<li class='b3'>"  +  item_quantity_arry.getitem(i)  + "</li>";
											str = str  + "<li class='b4'>" + (item_amount_arry.getitem(i)*item_quantity_arry.getitem(i)) + "</li>";
											//str = str + "<li class='b5'>"  + item_shipping_arry.getitem(i) +  "</li>";
											str = str + "<li class='b5'>"  +   tmpshippingcost  +  "</li>";

											str = str + "<li class='b6'><img src='storeimages/close_st01.png' id='" +  deleteitemname + "'></li>";
											str = str + "</ul>";
																						
										
										
										//alert("shipping num=" + item_shipping_arry.getitem(i));
										
											
											k = i + 1;
											
											
											//hiddenvars=	 "<form name='paypal-1' id='paypal-1' action='https://www.paypal.com/cgi-bin/webscr' method='post' class='form' >";
											hiddenvars=	hiddenvars + "<input type='hidden' name='item_name_"   + k + "' value='" +  item_name_arry.getitem(i) +  "'>";
											hiddenvars=	hiddenvars + "<input type='hidden' name='item_number_" + k + "' value='"  + item_number_arry.getitem(i) + "'>";
											hiddenvars=	hiddenvars + "<input type='hidden' name='amount_"      + k + "' value='" + item_amount_arry.getitem(i) +"'>";
											hiddenvars=	hiddenvars + "<input type='hidden' name='quantity_"    + k + "' value='" + item_quantity_arry.getitem(i) +"'>";
											hiddenvars=	hiddenvars + "<input type='hidden' name='shipping_"    + k + "' value='" + item_shipping_arry.getitem(i) +"'>";
											hiddenvars=	hiddenvars + "<input type='hidden' name='shipping2_"   + k + "' value='" +  item_shipping2_arry.getitem(i) +"'>";
											
											if (item_option1title_arry.getitem(i)!="" && item_option1title_arry.getitem(i)!="undefined" && item_option1title_arry.getitem(i)!="NAN" && item_option1title_arry.getitem(i)!="--option-not-set--" && item_option1title_arry.getitem(i)!=item_option1value_arry.getitem(i) &&  item_option1title_arry.getitem(i)!="none"){
																										
													hiddenvars=	hiddenvars + "<input type='hidden' name='on0_"   + k + "' value='" +  item_option1title_arry.getitem(i) +  "'>";
													hiddenvars=	hiddenvars + "<input type='hidden' name='os0_"   + k + "' value='" +  item_option1value_arry.getitem(i) +  "'>";
													
													
											}
											
											if (item_option2title_arry.getitem(i)!="" && item_option2title_arry.getitem(i)!="undefined" && item_option2title_arry.getitem(i)!="NAN" && item_option2title_arry.getitem(i)!="--option-not-set--" && item_option2title_arry.getitem(i)!=item_option2value_arry.getitem(i) &&    item_option2title_arry.getitem(i)!="none"){
													hiddenvars=	hiddenvars + "<input type='hidden' name='on1_"   + k + "' value='" +  item_option2title_arry.getitem(i) +  "'>";
													hiddenvars=	hiddenvars + "<input type='hidden' name='os1_"   +  k+ "' value='" +  item_option2value_arry.getitem(i) +  "'>";
													
													
											}
											isitemexists="true";
											itemtotal = itemtotal + (item_amount_arry.getitem(i) * item_quantity_arry.getitem(i));
											//shippingtotal = shippingtotal + parseInt(item_shipping_arry.getitem(i));
											shippingtotal = shippingtotal + ( (1*item_shipping_arry.getitem(i)) + ( (item_quantity_arry.getitem(i)-1)*item_shipping2_arry.getitem(i)   ) );
											
											
											
										
										hiddenvars_2co = hiddenvars_2co + "<input type='hidden' name='quantity"+  k  + "' value='" + item_number_arry.getitem(i) + "' >";
										hiddenvars_2co = hiddenvars_2co + "<input type='hidden' name='product_id"+  k  + "' value='" + item_2cprodid_arry.getitem(i) + "' >";
										
										 		
											
									}
									
									
									
										 
										
									
								
										if (isitemexists=="true"){
											
											
												hiddenvars=	hiddenvars +    "<input type='hidden' name='business' value='"      +  $.cookie('storepaypalid_ck')     + "'>";
												hiddenvars=	hiddenvars +    "<input type='hidden' name='currency_code' value='" +  $.cookie('storecurrency_ck')     + "'>";
												hiddenvars=	hiddenvars +    "<input type='hidden' name='lc' value='"            +   $.cookie('storedeflocation_ck') + "'>";
												hiddenvars=	hiddenvars + 	"<input type='hidden' name='cmd' value='_cart'>";
												hiddenvars=	hiddenvars + 	"<input type='hidden' name='upload' value='1'>";
												
												hiddenvars_paypal_form="<form name='paypal-1' id='paypal-1' action='https://www.paypal.com/cgi-bin/webscr' target='_blank' method='post' class='form' >";
												
												str1 = hiddenvars_paypal_form + hiddenvars + "<input type='submit' value='&raquo;  "  +   $.cookie('storecheckouttitle_paypal') +  "'  class='atcbtn'  name='checkout-paypal' id='checkout-paypal'>";
												str1  = str1 + "</form>";
												
												
												
												
												
											   hiddenvars_2co = hiddenvars_2co + "<input type='hidden' name='payment_processor' value='2c'>";
										       hiddenvars_2co = hiddenvars_2co +  "<input type='hidden' name='sid' value='" + $.cookie('store2checkoutid') +  "' >";
											   
											   hiddenvars_2checkout_form = "<form action='https://www.2checkout.com/2co/buyer/purchase' method='post' target='_blank' id=form2 name=form2>";
											   
											   
											   
                   								str1_2co = hiddenvars_2checkout_form + hiddenvars_2co + "<input type='submit' value='&raquo;  "  +    $.cookie('storecheckouttitle_2checkout') +  "'  class='atcbtn'  name='checkout-2co' id='checkout-2co'>";
												str1_2co  = str1_2co + "</form>";
												
												
																			
												
												
												if($.cookie('storepaypalselected')=="yes"){	
												
														//alert("paypalcode="+ str1);
														document.getElementById("buywithpaypal").innerHTML=str1;
														
														
												}
												
												
												
												
												
												if($.cookie('store2checkoutselected')=="yes"){	
														
														document.getElementById("buywith2co").innerHTML=str1_2co;
														
												}
												
												
												
												
												
											
											
										}else{
											
											
											document.getElementById("showcheckoutbtn").innerHTML="";
											 document.getElementById("ul-viewcart").innerHTML="";
											//document.getElementById("total").innerHTML="";
											str = "<p>Your cart is Empty</p>";
											isitemexists="false";
										}
										
										
											//alert("stage 6");
										
										if (isitemexists=="true"){				
												
											shippingtotal=	parseFloat(shippingtotal).toFixed(2); 
																
								    totalstr = "<li class='b1'><span>" + $.cookie('storeitemstotaltitle_ck')  +  " :  <sup>" + $.cookie('storecurrency_ck') + "</sup>" + itemtotal +  "</span></li>";
			                        totalstr = totalstr + "<li class='b5'><span>" + $.cookie('storeshippingtotaltitle_ck') + " : <sup>" + $.cookie('storecurrency_ck') +  "</sup>" +  shippingtotal  + "</span></li>";
										
											//alert("stage 7");
										
										}
									
									
									    
									
									
										$('#itembx').append($(str));
										
										$('#ctotals').append($(totalstr));
										
										
										
										return true;
										
									
 
					
				}
	
	
				
});

		
		
 
	
		
		
		
		
		